<%@ page language="Java" import="java.util.*,descriptor.*,cv.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<%
	CompaniesListDescriptor compList = (CompaniesListDescriptor)request.getAttribute("Companies");
	CompanyDescriptor companyDes = (CompanyDescriptor)request.getAttribute("CompanyDes");
	String companyID = (String)request.getAttribute("companyID");
	String viewComp = (String)request.getAttribute("viewComp");
	String error1 = (String)request.getAttribute("error1");
	String error2 = (String)request.getAttribute("error2");
%>

<html>
	<jsp:include page="CareerHeader.jsp" >
		<jsp:param name="pageTitle" value="Work Placement Management System - Career Officer" />
	</jsp:include>
	<body OnLoad="showmenu(document.getElementById('smenu2'));">
		<jsp:include page="CareerPageHeader.jsp"></jsp:include>
		<div id="container">
			<jsp:include page="CareerMenu.jsp" ></jsp:include>
			<div id="content">
				<h3 class="posttitle">Career Officer - Update a Company</h3>
				<div class="entry">
					<%
							int sizeList = compList.sizeCompaniesList(); 
							if(sizeList > 0)
							{
					%>
					<p>Select a company in the list to update its details</p>
					<br>
					<form name="frmcompanyList" method="post" style="margin-left: auto; margin-right: auto;">
						<input type="hidden" name="action" value="viewComp2"> 
						<fieldset>
							<legend>Select a Company</legend>
							<select OnChange="document.frmcompanyList.submit();" name="companyID">  
								<option value="">Select a company: </option>  
						<%
									
									for(int i=0; i<sizeList; i++)
									{
										String selected = "";
										String compName = compList.getCompanyDescriptors().get(i).getName();
										int compID = compList.getCompanyDescriptors().get(i).getId();
										if(companyID !=null && Integer.parseInt(companyID) == compID)
										{
											selected = "selected";
										}
						%>
								<option value="<%= compID %>" <%= selected %>><%= compName %></option>
						<%			
									}
						%>
							</select>
						</fieldset>
					</form>
					<br>
					<hr>
					<%
							}
							else
							{ 
								if(error1 != null)
					%>
									<p><%= error1 %></p>
					<%	
							} 
							
							if(viewComp != null)
							{
								if(viewComp.equals("1") && companyDes != null)
								{
					%>
							<jsp:include page="CareerCompanyUpdate2.jsp">
								<jsp:param name="compID" value="<%= companyDes.getId() %>" />
								<jsp:param name="compName" value="<%=  companyDes.getName()  %>" />
								<jsp:param name="compSector" value="<%= companyDes.getSector()  %>" />
								<jsp:param name="compAdress" value="<%= companyDes.getAdress()  %>" />
								<jsp:param name="compCity" value="<%=  companyDes.getCity() %>" />
								<jsp:param name="compCountry" value="<%= companyDes.getCountry()  %>" />
								<jsp:param name="compPhone" value="<%= companyDes.getPhone()  %>" />
								<jsp:param name="compEmail" value="<%= companyDes.getEmail()  %>" />
							</jsp:include>
					<% 			
								}
							}
							else
							{
								if(error2 != null)
								{				
					%>
									<p style="color:red; font-size: 10px;"><%= error2 %></p>
					<%
								}
							}	
					%>
				</div>
			</div>
			<jsp:include page="CareerPageFooter.jsp"></jsp:include>
		</div>
	</body>
</html>